package cn.itcast.hotel.controller;

import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.impl.HotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/hotel")
public class HotelConctroller {

    @Autowired
    private HotelService hotelService;

    @PostMapping("/list")
    public PageResult searchAndPage(@RequestBody RequestParams requestParams){
        PageResult search = hotelService.search(requestParams);
        return search;
    }

    @PostMapping("/filters")
    public Map<String , List<String>>filters(@RequestBody RequestParams requestParams){
        Map<String, List<String>> filters = hotelService.filters(requestParams);
        System.out.println(filters);
        return filters;
    }

    @GetMapping("/suggestion")
    public List<String> getSuggestions(@RequestParam("key") String predix){
        List<String> suggestions = hotelService.getSuggestions(predix);
        return suggestions;

    }

}
